import request from '@/utils/request'
const baseUrl = '/cz-rentbox/api/v1/invoiceNews' // 发票管理
// const baseUrlNew = '/cz-rentbox/api/v1/invoiceNews' // 发票管理

// import { updateInvoiceStatus } from '@/api/invoice'

//导出发票
export const exportInvoice = (data: any) => {
  return request({
    responseType: 'blob',
    url: baseUrl+'/exportInvoice',
    method: 'POST',
    data: data
  })
}


/**
 * 租箱订单，发票管理 表
 * # 参数说明：
    # orderIds;//订单号
    # invoiceDirection; 结算流向 1-收入 -1-支出.
    # businessId; 结算单位Id.
    # businessName; 结算单位.
    # invoiceStatus; 发票状态 5-未申请 10-待开票 15-已开票
    # closeStatus; 结算状态 5-未付 10-已付
    # creditCode; 统一社会信用代码
    # beginCreateDate:LocalDateTime; 申请时间区间
    # endCreateDate:LocalDateTime;   申请时间区间
    POST {{baseUrl}}/invoices/getInvoicePage
 */
export const getInvoicePage = (data: any) => {
return request({
url: baseUrl+'/getInvoicePage',
method: 'post',
data: data
})
}

export const getInvoicePageNew = (data: any) => {
return request({
url: baseUrl+'/getInvoiceListByOrderId',
method: 'POST',
data: data
})
}
/**
### 租箱订单，申请发票
##
POST {{baseUrl}}/invoices/addRentRequestInvoice 
data:{
    "invoiceOrder": "[{\"orderId\": 1814240791595909123,\"orderNo\": \"ZLOID2024080709676097\"},{\"orderId\": 1814240791595909122,\"orderNo\": \"ZLOID2024080630372663\"}]",
    "invoiceTitle":"发票抬头企业名称",
    "invoiceType":5,
    "invoiceContent":"租箱明细",
    "creditCode":"9464511851RFG1385D"
  }
*/
export const addRentRequestInvoice = (data: any) => {
return request({
url: baseUrl+'/addRentRequestInvoice',
method: 'post',
data: data
})
}

/**
### 租箱订单，申请发票 2024-11-07 业务变更  此申请发票接口为待提箱时就可提前申请，箱量为下单量，已提箱未完成时不可申请
##
POST {{baseUrl}}/invoices/addRentRequestInvoiceByStatus
data:{
    "invoiceOrder": "[{\"orderId\": 1814240791595909123,\"orderNo\": \"ZLOID2024080709676097\"},{\"orderId\": 1814240791595909122,\"orderNo\": \"ZLOID2024080630372663\"}]",
    "invoiceTitle":"发票抬头企业名称",
    "invoiceType":5,
    "invoiceContent":"租箱明细",
    "creditCode":"9464511851RFG1385D"
  } 
*/
export const addRentRequestInvoiceByStatus = (data: any) => {
return request({
url: baseUrl+'/addRentRequestInvoiceByStatus',
method: 'post',
data: data
})
}
//开发票
export const uploadingInvoice = (data: any) => {
return request({
      url: baseUrl+'/uploadingInvoice',
      method: 'post',
      data: data
  })
}
//发票红冲
export const redReversalInvoice = (data: any) => {
return request({
      url: baseUrl+'/redReversalInvoice',
      method: 'post',
      data: data
  })
}
//发送邮箱
export const sendInvoice = (data: any) =>{
    return request({
        url: baseUrl + "/sendingInvoiceToEmail",
        method: 'POST',
        data: data
    })
}
/**
###  集装箱公司上传发票（开发票）
## PUT  {{baseUrl}}/invoices/rentUploadingInvoice
data:{
  "id":1814240791595909129,
  "invoiceNo":"20240807096760971111111",
  "invoiceUrl":"[{\"name\":\"20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\",\"invoiceFileName\":\"国际贸易供应链数字平台需求分析(1).docx\",\"url\":\"http://47.122.3.254:9000/default/20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\"}]"
}
*/
export const rentUploadingInvoice = (data: any) => {
return request({
      url: baseUrl+'/rentUploadingInvoice',
      method: 'PUT',
      data: data
  })
}
// 开发票
export const addBillRequestInvoice = (data: any) => {
  return request({
    url: baseUrl + '/addBillRequestInvoice',
    method: 'POST',
    data:data
  })
}
/**
###  租箱订单 重rentUploadingInvoice
## PUT  {{baseUrl}}/invoices/reopenPunchRentOrderInvoice
data:{
  "id":1,
  "invoiceNo":"20240807096760971111133",
  "invoiceUrl":"[{\"name\":\"20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\",\"invoiceFileName\":\"国际贸易供应链数字平台需求分析(1).docx\",\"url\":\"http://47.122.3.254:9000/default/20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\"}]"
}
*/
export const reopenPunchRentOrderInvoice = (data: any) => {
return request({
url: baseUrl+'/reopenPunchRentOrderInvoice',
method: 'PUT',
data: data
})
}

/**
### 回调订单，申请发票
POST {{baseUrl}}/invoices/addCallbackRequestInvoice
data:{
    "invoiceOrder": "[{\"orderId\": 1814240791595909123,\"orderNo\": \"ZLOID2024080709676097\",\"orderId\": 1814240791595909122,\"orderNo\": \"ZLOID2024080630372663\"}]",
    "callbackOrderId":[1814237410068332545,1813422222054326274],
    "invoiceType":5,
    "businessId":1,
    "annulOverdueAmount":0,
    "businessName":"集装箱公司",
    "invoiceContent":"回调箱明细",
    "creditCode":"9464511851RFG1385D"
}
*/
export const addCallbackRequestInvoice = (data: any) => {
return request({
url: baseUrl+'/addCallbackRequestInvoice',
method: 'post',
data: data
})
}

/**
###  货代上传发票
## PUT  {{baseUrl}}/invoices/callbackUploadingInvoice
data:{
  "id":1814240791595909129,
  "invoiceNo":"20240807096760971111111",
  "invoiceUrl":"[{\"name\":\"20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\",\"invoiceFileName\":\"国际贸易供应链数字平台需求分析(1).docx\",\"url\":\"http://47.122.3.254:9000/default/20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\"}]"
}
*/
export const callbackUploadingInvoice = (data: any) => {
return request({
url: baseUrl+'/callbackUploadingInvoice',
method: 'PUT',
data: data
})
}

/**
###  支付箱贴费| 租箱款支付
## PUT  {{baseUrl}}/invoices/payBoxLabelInvoice 
data:{
  "id":1814240791595909129,
  "paymentMethod":5,
  "payDate":"2024-08-15T18:21:19",
  "payUrl":"[{\"name\":\"20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\",\"returnReceiptFileName\":\"国际贸易供应链数字平台电子回执单.docx\",\"url\":\"http://47.122.3.254:9000/default/20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\"}]"
}
*/
export const payBoxLabelInvoice = (data: any) => {
return request({
url: baseUrl+'/payBoxLabelInvoice',
method: 'PUT',
data: data
})
}

/**
# 根据发票id查询款项明细
# GET {{baseUrl}}/invoices/{id}
*/
export const getInvoicesInfo = (id: any) => {
return request({
url: baseUrl+'/'+id,
method: 'GET'
})
}


/**
### 购箱订单，申请发票
POST {{baseUrl}}/invoices/addPurchaseBoxRequestInvoice
data:{
    "invoiceOrder": "[{\"orderId\": 1814240791595909123,\"orderNo\": \"ZLOID2024080709676097\",\"orderId\": 1814240791595909122,\"orderNo\": \"ZLOID2024080630372663\"}]",
    "callbackOrderId":[1814237410068332545,1813422222054326274],
    "invoiceType":5,
    "businessId":1,
    "annulOverdueAmount":0,
    "businessName":"集装箱公司",
    "invoiceContent":"回调箱明细",
    "creditCode":"9464511851RFG1385D"
}
*/
export const addPurchaseBoxRequestInvoice = (data: any) => {
return request({
url: baseUrl+'/addPurchaseBoxRequestInvoice',
method: 'post',
data: data
})
}


/**
### 购箱订单 卖方公司开发票
PUT {{baseUrl}}/invoices/purchaseBoxUploadingInvoice
data:{
  "id":1814240791595909166,
  "invoiceNo":"20240807096760971111111",
  "invoiceUrl":"[{\"name\":\"20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\",\"invoiceFileName\":\"国际贸易供应链数字平台需求分析(1).docx\",\"url\":\"http://47.122.3.254:9000/default/20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\"}]",
   "rate":6.6,
  "payCurrency": "USD"
}
*/
export const purchaseBoxUploadingInvoice = (data: any) => {
return request({
url: baseUrl+'/purchaseBoxUploadingInvoice',
method: 'PUT',
data: data
})
}


/**
###  购箱订单 红冲发票
PUT  {{baseUrl}}/invoices/redPunchPurchaseBoxInvoice
data:{
  "id":1814240791595909166,
  "invoiceNo":"202408070967609711111122",
  "redInvoiceUrl":"[{\"name\":\"20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\",\"returnReceiptFileName\":\"国际贸易供应链数字平台电子回执单.docx\",\"url\":\"http://47.122.3.254:9000/default/20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\"}]"
}
*/
export const redPunchPurchaseBoxInvoice = (data: any) => {
return request({
url: baseUrl+'/redPunchPurchaseBoxInvoice',
method: 'PUT',
data: data
})
}

/**
### 购箱订单 重开发票
PUT {{baseUrl}}/invoices/reopenPunchPurchaseBoxInvoice
data:{
  "invoiceOrder": "[{\"orderId\": 5,\"orderNo\": \"MYOID2024083008103914\"},{\"orderId\": 6,\"orderNo\": \"MYOID2024083004813956\"}]",
  "id":1814240791595909166,
  "invoiceNo":"20240807096760971111133",
  "invoiceUrl":"[{\"name\":\"20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\",\"invoiceFileName\":\"国际贸易供应链数字平台需求分析(1).docx\",\"url\":\"http://47.122.3.254:9000/default/20240612/cddd81a833c64a7eab1da5c0aef8dfaf.docx\"}]"
}
*/
export const reopenPunchPurchaseBoxInvoice = (data: any) => {
return request({
url: baseUrl+'/reopenPunchPurchaseBoxInvoice',
method: 'PUT',
data: data
})
}

/**
###  订单取消,申请红冲    购箱和租箱已开票未支付时需先红冲发票再取消，回调没有此操作
## PUT  {{baseUrl}}/invoices/updateInvoiceStatus
data:{
  "invoiceIds": "[{\"id\": 1,\"orderIds\": [33,34]},{\"id\": 2,\"orderIds\": [35]}]"
}
*/
export const updateInvoiceStatus = (data: any) => {
return request({
url: baseUrl+'/updateInvoiceStatus',
method: 'PUT',
data: data
})
}



// ### 发票OCR识别
// POST {{baseUrl}}/invoices/invoiceOcr 
export const invoiceOcr = (data: any) => {
return request({
url: baseUrl+'/invoiceOcr',
method: 'POST',
  data: data,
// data:{
//   "invoiceUrl":"http://47.122.3.254:9000/default/template/发票.jpg"
// }
})
}
